# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=libical-glib
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.0.4
pkgrel=1
arch=('any')
pkgdesc="An iCalendar library based on libical and introspectable by GObject Introspection (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-libical"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-libxml2")
makedepends=("gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
options=('strip' 'staticlibs')
license=("LGPL 2.1")
url="https://www.gnome.org/"
source=(https://download.gnome.org/sources/${_realname}/${pkgver%.*}/${_realname}-${pkgver}.tar.xz
        001-win.patch)
sha256sums=('3e47c7c19a403e77a598cfa8fc82c8e9ea0b3625e2f28bdcec096aeba37fb0cd'
            '4e34ccb69bd5356071b4d0ee96cf5b7148f6ae7dd3815861dee4fbb8e99156fd')

prepare() {
  cd ${_realname}-${pkgver}

  patch -p1 -i ${srcdir}/001-win.patch

  autoreconf -fi
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  mkdir -p docs/reference/${_realname}/html
  cp -rf ../${_realname}-${pkgver}/docs/reference/${_realname}/html/* docs/reference/${_realname}/html

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-introspection=yes
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
